#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<string>
using namespace std;

//class Person
//{
//public:
//	string name;//名字
//	int age;	//年龄
//};
//class Student :public Person
//{
//public:
//	int stuid;	//学号
//};


//class Person
//{
//protected:
//	string _name;// 姓名
//	string _sex;// 性别
//	int _age;// 年龄
//};
//class Student : public Person
//{
//public:
//	int _No;// 学号
//};
//void Test()
//{
//	Student sobj;
//	// 1.子类对象可以赋值给父类对象/指针/引用
//	Person pobj = sobj;
//	Person* pp = &sobj;
//	Person& rp = sobj;
//
//	//2.基类对象不能赋值给派生类对象
//	//sobj=pobj;
//
//	// 3.基类的指针可以通过强制类型转换赋值给派生类的指针
//	pp = &sobj;
//	Student * ps1 = (Student*)pp; // 这种情况转换时可以的。
//	ps1->_No = 10;
//
//	pp = &pobj;
//	Student* ps2 = (Student*)pp; // 这种情况转换时虽然可以，但是会存在越界访问的问题
//	ps2->_No = 20;
//}


// Student的_num和Person的_num构成隐藏关系，可以看出这样代码虽然能跑，但是非常容易混淆
//class Person
//{
//protected:
//	string _name = "小李子"; // 姓名
//	int _num = 111;// 身份证号
//};
//class Student : public Person
//{
//public:
//	void Print()
//	{
//		cout << "姓名:" << _name << endl;
//		cout << "身份证号:" << Person::_num << endl;
//		cout << "学号:" << _num << endl;
//	}
//protected:
//	int _num = 999; // 学号
//};
//void Test1()
//{
//	Student s1;
//	s1.Print();
//};
//
//
//class A
//{
//public:
//	void fun()
//	{
//		cout << "func()" << endl;
//	}
//};
//class B : public A
//{
//public:
//	void fun(int i)
//	{
//		A::fun();
//		cout << "func(int i)->" << i << endl;
//	}
//};
//void Test2()
//{
//	B b;
//	b.fun(10);
//};


//class Person
//{
//public:
//	Person(const char* name)
//		: _name(name)
//	{
//		cout << "Person()" << endl;
//	}
//protected:
//	string _name;
//};
//class Student :public Person
//{
//public:
//	Student(const char* name, int num)
//		:Person(name)    //匿名对象在初始化列表初始
//		, _num(num)
//	{
//		cout << "Student()" << endl;
//	}
//protected:
//	int _num;
//};
//
//
//int main()
//{
//	Student s1("张三", 20);
//	return 0;
//}

//虚拟继承
class A
{
public:
	int _a;
};

//class B : public A
class B : virtual public A
{
public:
	int _b;
};

//class C : public A
class C : virtual public A
{
public:
	int _c;
};

class D : public B, public C
{
public:
	int _d;
};

int main()
{
	D d;
	d.B::_a = 1;
	d.C::_a = 2;
	d._a = 0;
	d._b = 3;
	d._c = 4;
	d._d = 5;

	return 0;
}
#include <queue>

namespace lh
{
    //BM46 最小的k个数
    //https://www.nowcoder.com/practice/6a296eb82cf844ca8539b57c23e6e9bf?tpId=295&tqId=23263&ru=/exam/oj&qru=/ta/format-top101/question-ranking&sourceUrl=%2Fexam%2Foj
    class Solution {
    public:
        vector<int> GetLeastNumbers_Solution(vector<int> input, int k) {
            vector<int>res;
            if (k == 0)
                return res;
            //默认大堆（降序）
            priority_queue<int, vector<int>>pq;
            for (auto num : input)
            {
                //如果不满直接插入
                if (pq.size() < k)
                {
                    pq.push(num);
                    continue;
                }
                if (pq.top() > num)
                {
                    pq.pop();
                    pq.push(num);
                }
            }
            while (!pq.empty())
            {
                res.push_back(pq.top());
                pq.pop();
            }
            return res;
        }
    };

    //BM47 寻找第K大
    //https://www.nowcoder.com/practice/e016ad9b7f0b45048c58a9f27ba618bf?tpId=295&tqId=44581&ru=/exam/oj&qru=/ta/format-top101/question-ranking&sourceUrl=%2Fexam%2Foj
    class Solution2 {
    public:
        int findKth(vector<int> a, int n, int K) {
            // write code here
            //O(N)
            priority_queue<int, vector<int>>pq(a.begin(), a.end());
            //O(K*logN)
            while (--K)
            {
                pq.pop();
            }
            return pq.top();
        }
    };
}